package controller;

import dao.DrugDAOImpl;
import utils.DispatcherUtils;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "DeteldrugServlet", value = "/deteldrug.do")
public class DeteldrugServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String drugid = request.getParameter("drugid");
        if(drugid!=null&&!drugid.equals("")){
            DrugDAOImpl drugDAO = new DrugDAOImpl();
            if(drugDAO.deleteDrug(Integer.parseInt(drugid))){
                response.sendRedirect("index.do");
            }else{
                DispatcherUtils.openErrWeb("删除商品失败，请联系工作人员","index.do",request,response);
            }
        }
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
